<template>
	<view>
		<u-navbar :custom-back="tui.goBack" title="注销账号" title-color="#36363A" :border-bottom="false"></u-navbar>
		<view class="main">
			<view class="tips">温馨提示：</view>
			<view class="mt-3">你的身份信息、账号信息和藏品信息将会被清空且无法恢复。</view>
			<view class="tips">注销须知：</view>
			<view class="mt-3">1、注销账号前，请先关闭钱包自动续费功能，并将钱包账户的余额全部提现。</view>
			<view class="mt-3">2、您的账号中如果有未出售的藏品、无法注销。</view>
			<view class="mt-3">3、账号注销后，账户下的订单记录无法找回，昵称、头像、钱包地址等个人信息均会被删除。</view>
			<view class="mt-3">4、注销后，该账号将无法登录。</view>
			<view class="loginOff-box">
				<view class="d-flex align-items-start">
					<u-checkbox-group width="40upx">
						<u-checkbox activeColor="#292940" size="30" v-model="isCheck" shape="circle"></u-checkbox>
					</u-checkbox-group>
					<span class=" fz-24 text-left text-999BA8">我已阅读并知晓，愿意承担注销账户带来的后果。</span>
				</view>
				<u-button type="default" hover-class="none" @click="showTrue" class="family-sc text-666978 fz-36 logOut">确认注销</u-button>
			</view>
		</view>
		<u-popup v-model="show" mode="center" border-radius="16" >
			<view class="album-box">
				<view class="wallet-popup-bg">
					<view class="order-wait-tip-padding d-flex justify-content-center align-items-center">
						<view class="order-wait-tip">
							<image src='/static/setting/warn-img.png' mode="aspectFill"></image>
						</view>
					</view>
					<view class="text-292940 fz-30 text-center">账号注销后无法恢复，确定注销吗？</view>
					<view class="popup-btn-box d-flex justify-content-between align-items-center" >
						<u-button type="text" class="text-666978 fz-32 btn-style" :loading="loading" @click="offconfirm">确认</u-button>
						<u-button type="text" class="text-ffffff fz-32 btn-style yellow-bg" @click="show = false">取消</u-button>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isCheck:false,
				show:false,
				loading:false
			}
		},
		methods: {
			showTrue(){
				if(!this.isCheck){
					return uni.$u.toast('请勾选阅读并知晓声明')
				}
				this.show = true
			},
			//注销账号
			offconfirm(){
				this.loading = true
				this.$store.dispatch('auth/logclose').then(res=>{
					this.$store.commit('auth/LOGIN_OUT')
					this.$store.commit('auth/SET_USER',null)
					this.$store.commit('user/SET_ALBUMLIST',[])
					this.$store.commit('wallet/SET_WALLET',[])
					uni.$u.toast('注销成功')
					setTimeout(()=>{
						this.loading = false
						uni.reLaunch({
							url:'/pages/tabBars/home'
						})
					},1000)
				}).catch(error=>{
					this.loading = false
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		width: 100%;
		padding: 0 30upx;
		box-sizing: border-box;
		color: #36363A;
		line-height: 44upx;
		.tips{
			font-size: 32upx;
			font-weight: bold;
			margin-top: 80upx;
		}
		.loginOff-box{
			position: fixed;
			bottom: calc(40upx + var(--window-bottom));
			.logOut{
				width: 690upx;
				height: 98upx;
				background: #292940;
				border-radius: 49upx;
				color: #ffffff;
				font-size: 36upx;
				margin-top: 35upx;
			}
		}
	}
	.album-box {
		width: 640upx;
		padding: 50upx 0upx;
		.wallet-popup-logo{
			width: 98upx;
			height: 98upx;
			margin:0 auto 0;
			image{
				width: 98upx;
				height: 98upx;
				vertical-align: top;
			}
		}
		.wallet-popup-bg{
			width: 640upx;
			border-radius: 16upx;
			.order-wait-tip-padding{
				padding-bottom: 30upx;
			}
			.order-wait-tip{
				width: 120upx;
				height: 120upx;
				image{
					width: 120upx;
					height: 120upx;
				}
			}
			.cancel-padding{
				padding-top: 56upx;
				margin-bottom: 40upx;
			}
			.popup-btn-box {
				padding: 0 40upx;
				box-sizing: border-box;
				margin-top: 59upx;
				.btn-style {
					width: 268upx;
					height: 88upx;
					background: rgba(216,217,225,0.5);
					border-radius: 49upx;
					margin-left:0 !important;
					margin-right:0 !important;
				}
			}
			
		}
		.cancel-bg{
			background: #ffffff !important;
		}
	}
</style>
